package application;
import gui.views.Main;
import guicemodules.GlobalContextModule;
import guicemodules.JAXBMetagrammarContextModule;
import guicemodules.LibraryArchiveModule;
import guicemodules.OperatorArchiveModule;
import guicemodules.OperatorDescriptionArchiveModule;
import guicemodules.SpecArchiveModule;
import guicemodules.TypeArchiveModule;
import guicemodules.ZippedArchiveModule;

import java.awt.EventQueue;
import java.awt.Font;
import java.awt.FontFormatException;
import java.io.IOException;

import com.google.inject.Guice;
import com.google.inject.Injector;

/**
 * 
 */

/**
 * @author Joshua Lockerman
 *
 */
public class Application {
    
    public static final Injector injector = Guice.createInjector(new GlobalContextModule(),
            new TypeArchiveModule(), new OperatorArchiveModule(), new SpecArchiveModule(),
            new JAXBMetagrammarContextModule(), new ZippedArchiveModule(),
            new OperatorDescriptionArchiveModule(), new LibraryArchiveModule());
    
    protected static Main main;
    
    public static final Font mathFont = Font.decode("Cambria Math").deriveFont(12);
    
    public static GlobalContext getContext()
    {
        return injector.getInstance(GlobalContext.class);
    }
    
    /**
     * @param args
     *            the command line arguments
     */
    public static void main(String... args)
    {
        // TODO
        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run()
            {
                try {
                    main = new Main();
                    main.setVisible(true);
                }
                catch(FontFormatException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                catch(IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        });
    }
}
